﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Template.Master" Inherits="System.Web.Mvc.ViewPage<JLL.China.Web.Areas.Portal.Models.BannerModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div id="page-heading">
         <a class="icons icon-circle-arrow-right"></a> <b><span class="show-listing">  Manange - Pages  </span> </b>
    </div>
    <div class="menu-nav">
        
    </div>
     <!-- end page-heading -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <img src="<%=Url.Content("~/Content/images/shared/side_shadowleft.jpg")%>" width="20"
                    height="300" alt="" />
            </th>
            <th class="topleft">
            </th>
            <td id="tbl-border-top">
                &nbsp;
            </td>
            <th class="topright">
            </th>
            <th rowspan="3" class="sized">
                <img src="<%=Url.Content("~/Content/images/shared/side_shadowright.jpg")%>" width="20"
                    height="300" alt="" />
            </th>
        </tr>
        <tr>
            <td id="tbl-border-left">
            </td>
            <td class="content-table-inner">
                <!--  start content-table-inner ...................................................................... START -->
                <div id="content-table-inner" style=" min-height: 288px;">
                     <!--  start message-blue -->
                         <% Html.RenderPartial("Measage");%>     
                          <!--  end message-blue -->
  <!--  start step-holder -->
      <!--  end step-holder -->
                    <form id="mainform" action="<%=Url.Content("~/") %>Portal/Pages" class="list_item_form" method="post">
                      <table border="0" width="100%" cellpadding="0" cellspacing="0" >
                       <td colspan="2" valign="top" style="padding-bottom: 18px;"><span style=" margin-right: 28px;"><b>+ List Page</b></span>
                        <input type="hidden" id="PageId" value="<%=(ViewData["ID"] != null)?ViewData["ID"].ToString():"" %>"/>
                        <select name="listpage" id="listpage" class="validate[required] chosen-select">
                       
                         <option value="">Please select</option>
                    <% foreach (var m in this.Model.ListPage)
                       { 
                        %>
                        <% if (m.ParentFID==0)
                           { %>
                        <option value="<%=m.ID%>" <%=(ViewData["ID"]!=null)?(ViewData["ID"].ToString()==m.ID.ToString())?"selected='selected'":"":"" %> ><%=m.Name%></option>
                         <%} %>
                       <%} %>
                       </select>
                       </td>
                       <% if (ViewData["ID"] != null)
                          {
                              if (ViewData["ID"].ToString() == "8")
                              { %>
                            <tr>
                                
                                <td style="padding-right:18px"><p><h1>Our Team HTML Content English</h1></p>                            <input type="hidden" name="OurTeamContentsID" value="<%=this.Model.OurTeam.ID %>"/>
                                    <textarea class="ckeditors" name="OurTeamContents" ><%=this.Model.OurTeam.Contents%></textarea>
                                </td>
                                <td><p><h1>Our Team HTML Content Local</h1></p>
                                    <textarea class="ckeditors" name="OurTeamContentsLocal"  ><%=this.Model.OurTeam.ContentsLocal%></textarea>
                                </td>
                            </tr>
                            <tr>
                               
                                <td style="padding-right:18px"><h1>Contact HTML Content English </h1>
                                          <input type="hidden" name="ContactContentsID" value="<%=this.Model.Contact.ID %>"/>
                                    <textarea class="ckeditors" name="ContactContents" ><%=this.Model.Contact.Contents%></textarea>
                                </td>
                                <td><p><h1>Contact HTML Content Local </h1></p>
                                    <textarea class="ckeditors" name="ContactContentsLocal"  ><%=this.Model.Contact.ContentsLocal%></textarea>
                                </td> 
                            </tr>
                            <tr>
                                            
                       <td align="right" colspan="2" style="padding-top:8px">
                           <input type="submit" value="Update Content" class="buttons" style="margin-right: 0 ;float: none"/>
                       </td>
                       </tr>
                       <%}
                              else
                              {
                                  if (this.Model.Page.Contents != null)
                                  {%>
                            
                                   <tr>
                               
                                <td style="padding-right:18px"><h1>Page HTML Content English </h1>
                                          <input type="hidden" name="PageContentsID" value="<%= this.Model.Page.ID %>"/>
                                    <textarea class="ckeditors" name="PageContents" ><%= this.Model.Page.Contents%></textarea>
                                </td>
                                <td><p><h1>Page HTML Content Local </h1></p>
                                    <textarea class="ckeditors" name="PageContentsLocal"  ><%= this.Model.Page.ContentsLocal%></textarea>
                                </td> 
                            </tr>
                                 <tr><th></th><td></td></tr>
                               <tr>
                                            
                       <td align="right" colspan="2" style="padding-top:8px">
                           <input type="submit" value="Update Content" class="buttons" style="margin-right: 0 ;float: none"/>
                       </td>
                       </tr>
                             <% }
                                  else
                                  {%>
                            
                                  <%}
                              }
                          }
                          else
                          {%>
                          
                          <%}%>
                
                       </table>
                        </form>
                       <!---LIST SIDE CONTENT-->
                       <br/>
                       <% if(ViewData["ID"] != null)
                          { %>
                      <table id="product-table" width="50%">
                       <h3>Current Side Content</h3>
                       <% if (ViewData["CountID"].ToString() == "0")
                          { %>
                         
                          <tr><td colspan="4" style="border: 0"> No side content has been set Global Banner will be displayed instead </td> </tr>                         
                       <% }
                          else
                          { %>
                     
                        <tr>
                            <th class="table-header-check"> <a style="color: white"><b>ID</b></a></th>
                            <th class="table-header-repeat line-left"><a>Banner Title</a></th>
                            <th class="table-header-repeat line-left"><a>Banner Type</a></th>
                            <th class="table-header-options line-left"><a>Option</a></th>
                        </tr>
                        <% string ListContent = "";
                           foreach (var m in this.Model.Banners)
                           {
                               ListContent += m.Banner_ID.ToString()+",";
                            %>
                           <tr>
                            <td align="center"><%= m.Banner_ID %></td>
                            <td style="padding: 8px"><%= m.Title %></td>
                            <td style="padding: 8px"><%= m.Type %></td>
                            <td style="padding: 10px">
                                <div><a  href="<%=Url.Content("~/Portal/Pages/Remove/"+m.Banner_ID.ToString()+"?pageid="+ViewData["ID"].ToString())%>" class="btnRemove info-tooltip remove-btn" >
                                         <img id="Img1" src="<%= Url.Content("~/Content/images/") %>Close.png" style="width: 24px;"/>
                                     </a></div>
                            </td>
                        </tr>
                          
                         <% } %>
                          <input type="hidden" id="listsidetable" value="<%=ListContent %>"/>
                        <% } %>
                          <tr><td colspan="4" style="padding: 8px;position: relative">
                                    <input type="button" class="buttons" style="margin-left: 8px;float: none" value="Add Side Content" id="btnAddContent"/>
                              
                         <div id="show-list-banner" style="position: relative" class="hidden"><br/>
                       <% string strarrayList = (ViewData["ListBanner"] != null) ? ViewData["ListBanner"].ToString() : "";
                          var arrayList = strarrayList.Split(',');

                       %>  
                            <select data-placeholder="Click here to select list banners" id="banners" name="banners" style="margin: 8px; width:338px;" class="validate[required] chosen-select" multiple tabindex="6">
                               <optgroup label="Static Banner">
                                    <% foreach (var m in this.Model.Statics)
                                       {
                                    %>
                                    
                                     <% if (arrayList.Contains(m.ID.ToString()))
                                        { %>
                                     
                                     <% }
                                        else
                                        { %>
                                         <option value="<%= m.ID %>"><%= m.Title %></option>
                                     
                                   <% }
                                       } %>
                               </optgroup>
                                <optgroup label="Dynamic Banner">
                                    <% foreach (var m in this.Model.Dynamic)
                                       {
                                    %>
                                    
                                     <% if (arrayList.Contains(m.ID.ToString()))
                                        { %>
                                    
                                     <% }
                                        else
                                        { %>
                                         <option value="<%= m.ID %>"><%= m.Title %></option>
                                     
                                   <% }
                                       } %>
                               </optgroup>
                           </select> 
                              <input type="button" class="buttons" style="margin-left: 388px;position: absolute;float: right;margin-top: -30px" value="Save" id="btnSave"/>
                              
                      </div>
                     
                       </td>
                       </tr>
                       
             
                       </table>
                       <% } %>
                 
 
                </div>
                <!--  end table-content  -->
                 </td>
            <td id="tbl-border-right">
            </td>
        </tr>
        <tr>
            <th class="sized bottomleft">
            </th>
            <td id="tbl-border-bottom">
                &nbsp;
            </td>
            <th class="sized bottomright">
            </th>
        </tr>
    </table>
</asp:Content> 

<asp:Content ID="Content2" ContentPlaceHolderID="CSS" runat="server">
<link href="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/jquery.validation/validationEngine.jquery.css")%>"
        rel="stylesheet" type="text/css" />
        <link href="<%=Url.Content("~/Content/css/mod-listing.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Scripts/chosen/chosen.css")%>" rel="stylesheet" type="text/css" />
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="JS" runat="server">
  <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine-en.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/chosen/chosen.jquery.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.js")%>" type="text/javascript"></script>
      <script src="<%=Url.Content("~/Scripts/ckeditor/ckeditor.js")%>" type="text/javascript"></script>

    <script type="text/javascript" src="<%=Url.Content("~/Scripts/ckeditor/adapters/jquery.js")%>"></script>

  <script type="text/javascript">
      $(document).ready(function() {

          $('.ckeditors').ckeditor();
          $(".chosen-select").chosen({
              allow_single_deselect: true
          });

          jQuery("#mainform").validationEngine({
              prettySelect: true,
              useSuffix: "_chzn",
              promptPosition: "bottomLeft",
              scroll: false
          });
          $("#listpage").bind('change', function() {
              window.location.href = BASE_URL + "Portal/Pages/Index/" + ($(this).val());
          });

          // Event Add
          $("#btnAddContent").click(function() {
              $("#banners").val("");
              $("#show-list-banner").removeClass("hidden");
          });
          //Save
          $("#btnSave").click(function() {
              var listable = $("#listsidetable").val();

              var arrbanner = $("#banners").val();
              if (arrbanner === null) {
                  $("#mainform").submit();
              }
              else {
                  //Send Ajax
                  if (listable !== undefined) {
                      arrbanner = listable + arrbanner;
                  }
                  
                  var PageID = $("#PageId").val();
                  var postpage = BASE_URL + "Portal/Pages/Add/" + PageID + "?list=" + arrbanner;
                  window.location.href = postpage;
              }

          });
          //Delete

          $(".btnRemove").click(function(e) {
              e.preventDefault(); //prevent default action for anchor
              var self = this;
              Confirm("Confirm removed the selected records?", function(yes) {
                  if (yes) {
                      $("#content-outer").showLoading();
                      window.location = self.href;
                  }

              });
          });

          function Confirm(question, callback) {
              // Content will consist of the question and ok/cancel buttons
              var message = $('<p />', { text: question }),
			             cancel = $('<button />', {
			                 text: 'Yes',
			                 click: function() { callback(true); }
			             }),
			            ok = $('<button />', {
			                text: 'No',
			                click: function() { callback(false); }
			            })
			           ;

              dialogue(message.add(ok).add(cancel), 'Confirm');
          }
          function dialogue(content, title) {
              /* 
              * Since the dialogue isn't really a tooltip as such, we'll use a dummy
              * out-of-DOM element as our target instead of an actual element like document.body
              */
              $('<div />').qtip(
		        {
		            content: {
		                text: content,
		                title: title
		            },
		            position: {
		                my: 'center', at: 'center', // Center it...
		                target: $(window) // ... in the window
		            },
		            show: {
		                ready: true, // Show it straight away
		                modal: {
		                    on: true, // Make it modal (darken the rest of the page)...
		                    blur: false // ... but don't close the tooltip when clicked
		                }
		            },
		            hide: false, // We'll hide it maunally so disable hide events
		            style: 'qtip-light qtip-rounded qtip-dialogue', // Add a few styles
		            events: {
		                // Hide the tooltip when any buttons in the dialogue are clicked
		                render: function(event, api) {
		                    $('button', api.elements.content).click(api.hide);
		                },
		                // Destroy the tooltip once it's hidden as we no longer need it!
		                hide: function(event, api) { api.destroy(); }
		            }
		        });
          }
      });
  </script>  
</asp:Content>
